package model

import (
	"gorm.io/gorm"
	__ "grpc/basic/proto"
)

// 收藏
type Favorite struct {
	gorm.Model
	UserId  int    `gorm:"type:int" json:"userId"`
	VideoId int    `gorm:"type:int" json:"videoId"`
	Status  string `gorm:"type:varchar(10)" json:"status"`
}

func (h *Favorite) AddFavorite(db *gorm.DB) error {
	return db.Debug().Create(&h).Error
}

func (h *Favorite) ListFavorite(db *gorm.DB) (list []*__.ListFavorite, err error) {
	err = db.Debug().Model(&Favorite{}).Select("user_id,video_id,status").Find(&list).Error
	return list, err
}
